export default {
    setHeaderTitle(state, routerName) { //设置标题
      switch(routerName) {
        case 'day' : 
          state.headerTitle = '当天信息'
          break
        case 'month' :
          state.headerTitle = '近期假期'
          break
        case 'year' : 
          state.headerTitle = '当年假期'
          break
        default:
          state.headerTitle = '当天信息'
          break
      }
    },
    setPlaceholder(state, routerName) { //设置placeholder
      let date = new Date();
      let year = date.getFullYear()
      let month = (date.getMonth()+1).toString().padStart(2, '0')
      let day = date.getDate().toString().padStart(2, '0')
      switch(routerName) {
        case 'day':
          state.placeholder =`格式：${year}${month}${day}（${year}年${month}月${day}日）`
          break
        case 'month':
          state.placeholder = `格式：${year}${month}（${year}年${month}月）`
          break
        case 'year' : 
          state.placeholder = `格式：${year}（${year}年）`
          break
        default:
          state.placeholder = `格式：${year}${month}${day}（${year}年${month}月${day}日）`
          break
      }
    },
    setMaxlength(state, routerName) { //设置搜索框的最大长度
      switch(routerName) {
        case 'day' : 
          state.maxlength = 8
          break
        case 'month' :
          state.maxlength = 6
          break
        case 'year' : 
          state.maxlength = 4
          break
        default:
          state.maxlength = 8
          break
      }
    },
    setField(state,routerName) {
      state.field = routerName
    },
    setErrorCode(state, errorCode) {
      state.errorCode = errorCode
    },
    setData(state, payLoad) {
      const {field, data} = payLoad
      switch (field) {
        case 'day':
          state.dayData = data
          break;
        case 'month':
          state.monthData = data
          break;
        case 'year':
          state.yearData = data
          break;
      }
    }
}